function get(url, callback) {
    var ajax = new XMLHttpRequest();
    ajax.onreadystatechange = () => {
        if (ajax.readyState == 4 && ajax.status == 200) {
            var json = ajax.responseText;
            var result = JSON.parse(json);
            callback(result);

        }
    }
    ajax.open("get",url);
    ajax.send(null);
}
function post(url, data, callback) {
    var ajax = new XMLHttpRequest();
    ajax.onreadystatechange = () => {
        if (ajax.readyState == 4 && ajax.status == 200) {
            var json = ajax.responseText;
            var result = JSON.parse(json);
            callback(result);

        }
    }
    ajax.open("post",url);
    // 设置提交数据的内容类型
    if (data instanceof String){
        // 表单提交参数
        ajax.setRequestHeader("Content-typee","application/x-www-form-urlencoded");
    } else if (data instanceof FormData){
        // 文件上传
        ajax.setRequestHeader("Content-type", "multipart/form-data");
    }
    ajax.send(data);
}
